/*  
	------------------------------------------------------------------------
	 NQ Core Library
	
	 Homepage: http://www.awzhome.de/
	------------------------------------------------------------------------
	
	This Source Code Form is subject to the terms of the Mozilla Public
	License, v. 2.0. If a copy of the MPL was not distributed with this
	file, You can obtain one at http://mozilla.org/MPL/2.0/.
   
	The Original Code is code of NQ Core Library.

	The Initial Developer of the Original Code is Andreas Weizel.
	Portions created by the Initial Developer are
	Copyright (C) 2012 Andreas Weizel. All Rights Reserved.
	
	Contributor(s): (none)
	
	------------------------------------------------------------------------
*/
using System;
using System.Collections;

namespace AWZhome.NQ.Core
{

	/// <summary>
	/// Sets a loading requirement for a component or service to make its presence
	/// dependent on the presence of another component.
	/// </summary>
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Assembly, Inherited = true, AllowMultiple = true)]
	public class NQComponentRequirementAttribute : Attribute
	{
		NQComponentRequirement compReq = new NQComponentRequirement();

		/// <summary>
		/// Initializes the attribute instance.
		/// </summary>
		/// <param name="compName">Name of the required component.</param>
		public NQComponentRequirementAttribute(string compName)
		{
			compReq.ComponentName = compName;
		}

		/// <summary>
		/// Gets/sets the version of the component, that the marked component/service requires.
		/// </summary>
		public string Version
		{
			get
			{
				return compReq.Version.ToString();
			}
			set
			{
				compReq.Version = new Version(value);
			}
		}

		/// <summary>
		/// Gets/sets the relational operator for the version constraint.
		/// </summary>
		public NQCondition Condition
		{
			get
			{
				return compReq.Condition;
			}
			set
			{
				compReq.Condition = value;
			}
		}

		/// <summary>
		/// Retrieves the requirement information as an instance of
		/// <see cref="AWZhome.NQ.Core.INQComponentRequirement">INQComponentRequirement</see>.
		/// </summary>
		public INQComponentRequirement ComponentRequirement
		{
			get
			{
				return compReq;
			}
		}
	}
}
